package aar.test.tessocr;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

import aar.test.tessocr.base.BaseActivity;

import aar.test.tessocr.utils.statuesBar;
import clx.tessocr.ocreng.R;


public class SplashActivity extends BaseActivity {

    private static  String TAG="SplashActivity";

    private ImageView splash_view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        if (Build.VERSION.SDK_INT >= 26){
         //你再调用。。。。。

            closeAndroidPDialog();
        }
        if(null!=getSupportActionBar()){
            getSupportActionBar().hide();
        }
        statuesBar.setStatusBarFullTransparent(this);
        initView();
        startAnim2();
    }


   private void initView(){
       splash_view=findViewById(R.id.splash_view);
   }

    private void startAnim2(  ) {

        AlphaAnimation alpah = new AlphaAnimation(0.0f, 1.0f);
        alpah.setDuration(3000);
        alpah.setFillAfter(true);
        splash_view.startAnimation(alpah);
        alpah.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {



            }

            @Override
            public void onAnimationEnd(Animation animation) {


                startActivity(new Intent(SplashActivity.this, Login1Activity.class));
//                startActivity(new Intent(SplashActivity.this, MainActivity.class));
                finish();


            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
    }






    private void closeAndroidPDialog(){
        try {
            Class aClass = Class.forName("android.content.pm.PackageParser$Package");
            Constructor declaredConstructor = aClass.getDeclaredConstructor(String.class);
            declaredConstructor.setAccessible(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            Class cls = Class.forName("android.app.ActivityThread");
            Method declaredMethod = cls.getDeclaredMethod("currentActivityThread");
            declaredMethod.setAccessible(true);
            Object activityThread = declaredMethod.invoke(null);
            Field mHiddenApiWarningShown = cls.getDeclaredField("mHiddenApiWarningShown");
            mHiddenApiWarningShown.setAccessible(true);
            mHiddenApiWarningShown.setBoolean(activityThread, true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }



}
